<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>后台管理系统 - {%SYS_LOGIN}</title>
<load href='__TMPL__Static/Css/login.css' />
<load href="__TMPL__Static/Js/jquery.js" />
<script type="text/javascript">
<!--
//指定当前组模块URL地址 
var AJAX_LOADING = '{%AJAX_LOADING}';
var AJAX_ERROR = '{%AJAX_ERROR}';
//-->
</script>
</head>
<body class="login">
<div class="logo">
	后台登陆
</div>
<div class="content">
	<form class="form-vertical login-form" method='post' name="login" id="login" action="{:U('Public/checkLogin')}" >
		<h3 class="form-title">Login to your account</h3>
		<div class="control-group">
			<label class="control-label visible-ie8 visible-ie9"></label>
			<div class="controls">
				<div class="input-icon left">
					<i class="icon-user"></i>
					<input class="m-wrap placeholder-no-fix" type="text" placeholder="用户名" name="admin_name" id="admin_name"/>
				</div>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label visible-ie8 visible-ie9"></label>
			<div class="controls">
				<div class="input-icon left">
					<i class="icon-lock"></i>
					<input class="m-wrap placeholder-no-fix" type="password" placeholder="密码" name="admin_pwd" id="admin_pwd"/>
				</div>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label visible-ie8 visible-ie9"></label>
			<div class="controls">
				<div class="input-icon left">
					<i class="icon-verify"></i>
					<input class="m-wrap placeholder-no-fix" type="text" placeholder="验证码" name="verify" id="verify"/>
					<img id="verifyImg" src="{:u('Public/verify')}"  align="absmiddle" alt="{%FRESH_VERIFY_TIP}" title="{%FRESH_VERIFY_TIP}">
				</div>
			</div>
		</div>
		<div class="form-actions">
			<button type="submit" class="btn green pull-right">
			Login <i class="m-icon-swapright m-icon-white"></i>
			</button>   
			<input type="hidden" name="ajax" value="1">
		</div>
	</form>
</div>
</body>
<script type="text/javascript">
jQuery(function($){
	if(top.location != self.location)
	{
		top.location.href = self.location.href;
		return;
	}
	
	$("#verifyImg").click(function(){
		fleshVerify();
	});
	
	$(document).keypress(function(e){
		if(e.keyCode == 13)
		{
			login()
		}
	});
	
	$("#login").submit(function(){
		login();
		return false;
	});
});

function login()
{
	$("#resultMsg").stop().removeClass('error').addClass('loading').html(AJAX_LOADING).show();
	
	$.ajax({
		url: "{:U('Public/checkLogin')}",
		type:"POST",
		cache: false,
		data:$("#login").serialize(),
		dataType:"json",
		error: function(){
			$("#resultMsg").addClass('error').html(AJAX_ERROR).show().fadeOut(5000);
		},
		success: function(result){
			$("#resultMsg").hide();
			if(result.status==1)
				location.href = '__APP__';
			else
			{
				$("#resultMsg").addClass('error').html(result.info).show().fadeOut(5000);
				fleshVerify();
			}
		}
	});
}

function fleshVerify()
{
	var time = new Date().getTime();
	$("#verifyImg").attr('src',"{:U('Public/verify')}&type=gif&rand="+time);
}
</script>
</html>